package minMaxGame;

public class Solution {
    public int minMaxGame(int[] nums) {
        return f(nums);
    }
    private int f(int[] nums) {
        if(nums.length==1) {
            return nums[0];
        }
        int n = nums.length;
        int[] newNums = new int[n/2];
        for (int i = 0; i < n; i+=2) {
            int index = i/2;
            if(index%2 ==0) {
                newNums[index] = Math.min(nums[i],nums[i+1]);
            }else {
                newNums[index] = Math.max(nums[i],nums[i+1]);
            }
        }
        return f(newNums);
    }
}
